package com.aaa.rabbitmq.one.util;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.Channel;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class RabbitMQUtil {

    //获取信道
    public static Channel getChannel() throws IOException, TimeoutException {
        //创建链接工厂
        ConnectionFactory factory = new ConnectionFactory();
        //工厂IP 链接mq的队列
        factory.setHost("127.0.0.1");
        factory.setPassword("guest");
        factory.setUsername("guest");
        factory.setPort(5672);

        //获取链接
        Connection connection = factory.newConnection();
        //获取信道
        Channel channel = connection.createChannel();
        return channel;
    }
}
